package com.lau.common.vo;

import com.lau.common.constant.ConstEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author mohan lau
 * @version 1.0
 * @description: TODO
 * @classname 公共返回对象
 * @date 2021/10/24 20:48
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseVo{
    
    private long code;
    private String message;
    private Object data;

    /**
     * 成功
     * @return
     */
    public static ResponseVo success(){
        return new ResponseVo(ConstEnum.SUCCESS.getCode(), ConstEnum.SUCCESS.getMsg(), null);
    }

    /**
     * 成功带结果
     * @param data
     * @return
     */
    public static ResponseVo success(Object data){
        return new ResponseVo(ConstEnum.SUCCESS.getCode(), ConstEnum.SUCCESS.getMsg(), data);
    }

    /**
     * 失败
     * @return
     */
    public static ResponseVo error(ConstEnum constEnum){
        return new ResponseVo(constEnum.getCode(), constEnum.getMsg(), null);
    }

    /**
     * 失败
     * @return
     */
    public static ResponseVo error(ConstEnum constEnum, String msg){
        return new ResponseVo(constEnum.getCode(), msg, null);
    }
    
    /**
     * 失败带结果
     * @param constEnum
     * @param data
     * @return ResponseVo
     */
    public static ResponseVo error(ConstEnum constEnum,Object data){
        return new ResponseVo(constEnum.getCode(), constEnum.getMsg(), data);
    }
}
